// 登录用户名长度与值验证
$(document).ready(function(){
	var lnamelen = document.getElementById("lname");
	var progress = document.getElementById("name1");
	var begin_classname = progress.className;
	lnamelen.onkeyup = function(){
		var val = this.value;
		var len = val.length;
		var nreg = /^[a-zA-Z0-9_-]{4,14}$/;
		if(len>=0 && len<=3){
			if(nreg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}
		}else if(len>=4 && len<=6){
			if(nreg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-info");
			}
		}else if(len>=7 && len<=14){
			if(nreg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-success");
			}
		}else if(len>=15){
			if(nreg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}
		}
}
});
// 登录密码长度与值验证
$(document).ready(function(){
	var lnamelen = document.getElementById("lpass");
	var progress = document.getElementById("pass1");
	var begin_classname = progress.className;
	lnamelen.onkeyup = function(){
		var val = this.value;
		var len = val.length;
		var preg = /^[a-zA-Z0-9_-]{4,14}$/;
		if(len>=0 && len<=4){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}
		}else if(len>=5 && len<=9){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-info");
			}
		}else if(len>=10 && len<=14){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-success");
			}
		}else if(len>=15){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}
		}
}
});

// 注册用户名长度与值验证
$(document).ready(function(){
	var lnamelen = document.getElementById("rname");
	var progress = document.getElementById("name2");
	var begin_classname = progress.className;
	lnamelen.onkeyup = function(){
		var val = this.value;
		var len = val.length;
		var preg = /^[a-zA-Z0-9_-]{4,14}$/;
		if(len>=0 && len<=3){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}
		}else if(len>=4 && len<=6){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-info");
			}
		}else if(len>=7 && len<=14){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-success");
			}
		}else if(len>=15){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}
		}
}
});

// 注册邮箱格式验证
$(document).ready(function(){
	var lnamelen = document.getElementById("remail");
	var progress = document.getElementById("email2");
	var begin_classname = progress.className;
	lnamelen.onkeyup = function(){
		var preg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

		if(preg.test(lnamelen.value)!=true){
			progress.setAttribute("class",begin_classname + " tip-bg-danger");
		}else{
				progress.setAttribute("class",begin_classname + " tip-bg-success");
			}
}
});

// 注册电话/手机号长度与格式验证
$(document).ready(function(){
	var lnamelen = document.getElementById("rtel");
	var progress = document.getElementById("telphone2");
	var begin_classname = progress.className;
	lnamelen.onkeyup = function(){
		var preg = /((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/;
		if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-success");
			}
}
});

// 注册密码长度与值验证
$(document).ready(function(){
	var lnamelen = document.getElementById("rpassword");
	var progress = document.getElementById("pass2");
	var begin_classname = progress.className;
	lnamelen.onkeyup = function(){
		var val = this.value;
		var len = val.length;
		var preg = /^[a-zA-Z0-9_-]{4,14}$/;
		if(len>=0 && len<=4){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}
		}else if(len>=5 && len<=9){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-info");
			}
		}else if(len>=10 && len<=14){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-success");
			}
		}else if(len>=15){
			if(preg.test(lnamelen.value)!=true){
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}else{
				progress.setAttribute("class",begin_classname + " tip-bg-danger");
			}
		}
}
});
// 注册密码二次值验证
$(document).ready(function(){
	var lnamelen = document.getElementById("rpassword");
	var snamelen = document.getElementById("spassword");
	var progress = document.getElementById("pass3");
	var begin_classname = progress.className;
	snamelen.onkeyup = function(){
		var val = this.value;
		var sval = lnamelen.value;
		if(val!=sval){
			progress.setAttribute("class",begin_classname + " tip-bg-danger");
		}else{
			progress.setAttribute("class",begin_classname + " tip-bg-success");
		}
}
});